//
//  SubOutSickerViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/25.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "InSickerViewModel.h"
#import "InPatientModel.h"
@interface InSickerViewModel ()
@property (nonatomic,strong) NSDictionary *dic;

@end

@implementation InSickerViewModel

-(instancetype)initWithType:(InSickerType)type doctor:(NSString *)doctor department:(NSString *)depart page:(NSInteger)page{
    //{db:"OracleString",SqlNo:"21",主管医生工号:"0802",Page:"1"}
    //{db:"OracleString",SqlNo:"24",科室编码:"010713",主管医生工号:"0802",Page:"1"}
    NSString *pageNum = [NSString stringWithFormat:@"%ld",page];
    if (type == InSickerTypePersonal) {
        _dic = @{@"db":@"OracleString",@"SqlNo":@"21",@"主管医生工号":doctor,@"Page":pageNum};
    }else{
        _dic = @{@"db":@"OracleString",@"SqlNo":@"24",@"科室编码":depart,@"医生工号":doctor,@"Page":pageNum};
    }
    return [self init];
}

-(void)getInSickerInfoSuccess:(void (^)(NSArray *))completion{
    NSString *url = [NSString stringWithFormat:@"%@%@",HOSPITAL_URL,COMMON_URL];
    [NetWorker getCommonDatasWithURLStr:url body:_dic success:^(id result) {
        NSArray *arr = [JsonHelper arrayWithJsonString:result[@"Entity"]];
        NSMutableArray *modelArr = [NSMutableArray array];
        for (NSDictionary *dic in arr) {
            InPatientModel *model = [InPatientModel yy_modelWithDictionary:dic];
            [modelArr addObject:model];
        }
        completion(modelArr);
    } failure:^(id result) {
        completion([NSArray array]);
    }];

}

@end
